Alex Martsinovich

Software Engineer
Home Posts Github LinkedIn

List of True Things About Elixir Logger Handlers and Backends

Dear reader, I am easily confused by loggers. For a long time, the Elixir logger was simple enough that I could live with it. But starting with version 1.15, something changed, and now I'm confused.

Luckily for me, Elixir.Logger documentation does an excellent job explaining everything. The problem is that it's a lengthy read and I need a refresher the moment I take my eyes off it.

This post is an attempt to complement the official docs by not adding more documentation, but rather by taking things out.

About Logger Handlers

About Logger Backends

About Extension Points

┌──────┐
│ Logs │
└──┬───┘
   │
   ├───────────────────┬───────────────────┐
   │                   │                   │
   ▼                   ▼                   ▼
┌──────────────┐┌──────────────┐┌──────────────────────┐
│logger handler││logger handler││LoggerBackends.Handler│
└──────────────┘└──────────────┘└──────────┬───────────┘
                                           │
                                     ┌─────┴─────┐
                                     │           │
                                     ▼           ▼
                                ┌──────────┐┌──────────┐
                                │  logger  ││  logger  │
                                │ backend  ││ backend  │
                                └──────────┘└──────────┘
I imagine LoggerBackends as a mama duck who protects its little backendlings from the need to implement overload protection

List of Questionable Advice

  1. If you have a pre-1.15 Elixir app on your hands, migrate it to logger handlers.
  2. Forget logger backends exist to avoid confusion.
  3. Whenever you need to customize your logging stack, try doing it with filters and formatters.
  4. If it doesn't work, consider remembering logger backends exist and implement your own to piggyback on built-in overload protection.
  5. If you still need to implement a custom logger handler, godspeed 🫡